﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.EasyBus.MessageQueue
{
    /// <summary>
    /// 消息终结点接口
    /// </summary>
    public interface IEndpoint
    {
        /// <summary>
        /// 是否同步处理消息
        /// </summary>
        bool IsSynchronization { get; set; }

        /// <summary>
        /// 获取消息通道
        /// </summary>
        /// <returns></returns>
        IChannel GetChannel();
    }

    /// <summary>
    /// 消息终结点基类
    /// </summary>
    public abstract class EndpointBase : IEndpoint
    {
        /// <summary>
        /// 是否同步处理消息
        /// </summary>
        public bool IsSynchronization { get; set; }

        /// <summary>
        /// 获取消息通道
        /// </summary>
        /// <returns></returns>
        public abstract IChannel GetChannel();

        /// <summary>
        /// 重写比较函数
        /// </summary>
        /// <param name="obj">被比较对象</param>
        /// <returns></returns>
        [Obsolete("用来比较Endpoint是否相等的重写，用不到了")]
        public override bool Equals(object obj)
        {
            #region 原用来比较Endpoint的代码

            //if (!obj.GetType().FullName.Equals(this.GetType().FullName))
            //{
            //    return false;
            //}
            //else 
            //{
            //    return this.EndpointEqualsCore(obj);
            //}

            #endregion

            return base.Equals(obj);
        }

        /// <summary>
        /// 终结点比较核心函数
        /// </summary>
        /// <param name="obj">被比较对象</param>
        /// <returns></returns>
        [Obsolete]
        public abstract bool EndpointEqualsCore(object obj);
    }
}
